package com.wisdom.benefit.jufa.product;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.RelativeLayout;

import com.wisdom.benefit.jufa.R;
import com.wisdom.benefit.jufa.base.BaseActivity;
import com.wisdom.benefit.jufa.widget.Mylistview;

import java.util.ArrayList;

public class ChooseCityActivity extends BaseActivity {
    private Mylistview lv;
    private RelativeLayout backRl;
    private ChooseCityAdapter chooseCityAdapter;
    private ArrayList<String> datas;

    @Override
    protected int getLayout() {
        return R.layout.activity_choose_city;
    }

    @Override
    protected void initViews() {
        //城市列表
        lv = findViewById(R.id.choose_city_lv);
        //返回按钮
        backRl = findViewById(R.id.choose_city_back);
        setData();
        setClick();
    }

    /**
     * 设置监听
     */
    private void setClick() {
        //返回按钮
        backRl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //城市列表
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(ChooseCityActivity.this, AddAccountActivity.class);
                intent.putExtra("city", datas.get(position));
                setResult(RESULT_OK, intent);
                finish();
            }
        });
    }

    private void setData() {
        datas = new ArrayList<>();
        datas.add("中国香港");
        datas.add("中国北京");
        datas.add("中国上海");
        datas.add("中国杭州");
        datas.add("中国武汉");
        datas.add("中国天津");
        datas.add("中国深圳");
        datas.add("中国广州");
        datas.add("中国重庆");

        chooseCityAdapter = new ChooseCityAdapter(datas, ChooseCityActivity.this);
        lv.setAdapter(chooseCityAdapter);
    }

    @Override
    protected int getTitleStringRes() {
        return 0;
    }
}
